package com.restaurant.application.minifacade.data;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;
import java.util.stream.Collectors;

public class ShopBookingTime implements PickableBean {

    public static final String FN_SHOPID = "shopId";
    public static final String FN_SHOPNAME = "shopName";
    public static final String FN_BOOKINGTIME = "bookingTime";
    public static final String FN_SERVICES = "services";
    
    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_SHOPID,
            FN_SHOPNAME,
            FN_BOOKINGTIME,
            FN_SERVICES);
    
    private String shopId;
    private String shopName;
    private List<BookingTime> bookingTime;
    private List<String> services;

    public ShopBookingTime(String shopId, String shopName, List<BookingTime> bookingTime, List<String> services) {
        setShopId(shopId);
        setShopName(shopName);
        setBookingTime(bookingTime);
        setServices(services);
    }

    public ShopBookingTime() {
    }

    public ShopBookingTime duplicate() {
        ShopBookingTime result = new ShopBookingTime();
        result.shopId = this.shopId;
        result.shopName = this.shopName;
        result.bookingTime = this.bookingTime == null ? null : this.bookingTime.stream().map(e1 -> e1 == null ? null : e1.duplicate()).collect(Collectors.toList());
        result.services = this.services == null ? null : this.services.stream().map(e2 -> e2).collect(Collectors.toList());
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String value) {
        this.shopId = value;
    }

    public ShopBookingTime withShopId(String value) {
        setShopId(value);
        return this;
    }

    public ShopBookingTime withShopId(String value, String defaultValue) {
        setShopId(value == null ? defaultValue : value);
        return this;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String value) {
        this.shopName = value;
    }

    public ShopBookingTime withShopName(String value) {
        setShopName(value);
        return this;
    }

    public ShopBookingTime withShopName(String value, String defaultValue) {
        setShopName(value == null ? defaultValue : value);
        return this;
    }

    public List<BookingTime> getBookingTime() {
        if (bookingTime == null) {
            bookingTime = Lists.newArrayList();
        }
        return bookingTime;
    }

    public void setBookingTime(List<BookingTime> value) {
        this.bookingTime = value;
    }

    public ShopBookingTime withBookingTime(List<BookingTime> value) {
        setBookingTime(value);
        return this;
    }

    public ShopBookingTime withBookingTime(List<BookingTime> value, List<BookingTime> defaultValue) {
        setBookingTime(value == null ? defaultValue : value);
        return this;
    }

    public ShopBookingTime addBookingTime(BookingTime value) {
        if (bookingTime == null) {
            bookingTime = Lists.newArrayList();
        }
        this.bookingTime.add(value);
        return this;
    }

    public List<String> getServices() {
        if (services == null) {
            services = Lists.newArrayList();
        }
        return services;
    }

    public void setServices(List<String> value) {
        this.services = value;
    }

    public ShopBookingTime withServices(List<String> value) {
        setServices(value);
        return this;
    }

    public ShopBookingTime withServices(List<String> value, List<String> defaultValue) {
        setServices(value == null ? defaultValue : value);
        return this;
    }

    public ShopBookingTime addServices(String value) {
        if (services == null) {
            services = Lists.newArrayList();
        }
        this.services.add(value);
        return this;
    }
    
    public Object getValueOf(String name) {
        switch (name) {
            case "shopId":
                return getShopId();
            case "shopName":
                return getShopName();
            case "bookingTime":
                return getBookingTime();
            case "services":
                return getServices();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof ShopBookingTime)) return false;
        return signature().equals(((ShopBookingTime) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean ShopBookingTime has no signature defined, no hash code or equals possible.");
    }
}
